package com.tanhua.server.interceptor;

import com.tanhua.domain.db.User;

public class UserHolder {
    private static ThreadLocal<User> threadLocal = new ThreadLocal<>();

    //向当前线程存储值
    public static void set(User user){
        threadLocal.set(user);
    }

    //从当前线程获取值
    public static User get(){
        User user = threadLocal.get();
        return user;
    }

    //获取当前用户的id
    public static Long getUserId(){
        return get().getId();
    }
}
